<template>
  <div style="height:111px;overflow:hidden; ">
    <el-card shadow="never" class="box-card">
      <div slot="header" class="clearfix">
        <span>一周安排</span>
      </div>
      <el-table :show-header="false" :data="arrange" class="left_menu_side">
        <el-table-column :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <a @click="showSingle(scope.row)">{{scope.row.name}}</a>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script type="text/javascript">
  import { ACCESS_TOKEN } from '@/store/mutation-types'
  import Vue from 'vue'
  import { getCurrentWeekDate, openIFrame } from '@/utils/util'

  export default {
    data() {
      return {
        arrange: [
          { name: '', type: 1,path:'/LeaderWork' },
          { name: '', type: 2,path:'/GlobalWork' }
        ],
        off1: []
      }
    },
    mounted() {
      this.arrange[0].name = '局领导一周日程安排(' + getCurrentWeekDate() + ')'
      this.arrange[1].name = '全局一周工作安排(' + getCurrentWeekDate() + ')'
    },
    methods: {
      showSingle(record) {
        let baseUrl = process.env.VUE_APP_WORK_API
        let ticket = Vue.ls.get(ACCESS_TOKEN)
        let params = {
          'ticket': ticket,
          'type': record.type
        }
        this.getRequest('/common/GetWeekWorkSchedule', params).then(res => {
          //处理返回的url
          let reUrl = res.split('&')[1].split('?')
          let url = baseUrl + reUrl[0].replace('redirect=', '') + '?' + reUrl[1]
          openIFrame(record.path, record.path, record.name, url)
          this.$router.push({ name: record.path })
        })
      }
    }
  }
</script>